using System.Collections.Generic;
using System.Threading.Tasks;
using JobToDdd.Application.RequirementApp.Dto;
using JobToDdd.Domain.JobInfo;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace JobToDdd.Application.RequirementApp
{
    public class RequirementService : ApplicationService, IRequirementService
    {
        private readonly IRepository<Requirement> _requirementRepo;
        private readonly IRepository<City> _cityRepo;
        public RequirementService(IRepository<Requirement> requirementRepo, IRepository<City> cityRepo)
        {
            _cityRepo = cityRepo;
            _requirementRepo = requirementRepo;
        }

        public async Task<List<RequriementDto>> GetRequriementDtos()
        {
            var requirements = await _requirementRepo.GetListAsync();
            var cities = await _cityRepo.GetListAsync();
            var educations = new Requirement().GetEducations(requirements);
            var welfares = new Requirement().GetWelfares(requirements);
            var cityNames = new City().GetCityName(cities);

            var requirementDtos = new List<RequriementDto>
            {
                new RequriementDto
                {
                    RequriementKey = "工作经验",
                    RequriementItems = educations,
                    Selected = null
                },
                new RequriementDto
                {
                    RequriementKey = "工作福利",
                    RequriementItems = welfares,
                    Selected = null
                },
                new RequriementDto
                {
                    RequriementKey = "所在城市",
                    RequriementItems = cityNames,
                    Selected = null
                }
            };
            return requirementDtos;
        }
    }
}